package com.sxpro;
import java.util.ArrayList;
import java.util.List;

//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) {
        //TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
        // 查看 IntelliJ IDEA 建议如何修正。
        System.out.printf("Hello and welcome!");
    }
}

class Subject {
    private String subjectName;

    public Subject(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getSubjectName() {
        return subjectName;
    }
}

class Instructor {
    private String name;
    private List<Subject> subjects;

    public Instructor(String name, Department department) {
        this.name = name;
        this.subjects = new ArrayList<>();
    }

    public void addSubject(Subject subject) {
        if (subjects.size() < 3) { // 每个教师教授1-3门课程
            subjects.add(subject);
        } else {
            System.out.println(name + " cannot teach more than 3 subjects.");
        }
    }

    public List<Subject> getSubjects() {
        return subjects;
    }

    public String getName() {
        return name;
    }
}

class Department {
    private List<Instructor> instructors;
    private List<Subject> subjects;

    public Department(String departmentName) {
        this.instructors = new ArrayList<>();
        this.subjects = new ArrayList<>();
    }

    public void addInstructor(Instructor instructor) {
        instructors.add(instructor);
    }

    public void addSubject(Subject subject) {
        subjects.add(subject);
    }

    public List<Instructor> getInstructors() {
        return instructors;
    }
}

class Student {
    private String name;
    private List<Subject> enrolledSubjects;

    public Student(String name) {
        this.name = name;
        this.enrolledSubjects = new ArrayList<>();
    }

    public void enrollSubject(Subject subject) {
        if (enrolledSubjects.size() < 5) { // 学生参加1-5门课程
            enrolledSubjects.add(subject);
        } else {
            System.out.println(name + " cannot enroll in more than 5 subjects.");
        }
    }

    public List<Subject> getEnrolledSubjects() {
        return enrolledSubjects;
    }

    public String getName() {
        return name;
    }
}

class School {
    private List<Department> departments;
    private List<Student> students;

    public School() {
        this.departments = new ArrayList<>();
        this.students = new ArrayList<>();
    }

    public void addDepartment(Department department) {
        departments.add(department);
    }

    public void addStudent(Student student) {
        students.add(student);
    }

    public List<Department> getDepartments() {
        return departments;
    }

    public List<Student> getStudents() {
        return students;
    }
}